import javax.swing.*;
import java.util.Scanner;

public class test9 {
    //斐波那契数列

        public static int fibonacci(int n) {
            if (n<=0){
               return 0;
            }else if (n==1){
                return 1;
            }

            int prev1=0;
            int prev2=1;
            int current=0;

            for (int i=2;i<=n;i++){
                current=prev1+prev2;
                prev1=prev2;
                prev2=current;

            }
            return current;
        }

        public static void main(String[] args) {
            //int n = 10; // 你可以改变这个值来计算不同项的斐波那契数
            System.out.println("请输入你要想寻找的项：");
            Scanner scanner=new Scanner(System.in);
            int n=scanner.nextInt();
            System.out.println("斐波那契数列的第 " + n + " 项是: " + fibonacci(n));
        }
    }

